home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xman / vendor.c < prev    next >
C/C++ Source or Header  |  1994-09-27  |  5KB  |  201 lines

  1.  
  2. /* Vendor-specific data structures and operations */
  3.  
  4. #include "globals.h"
  5. #include "vendor.h"
  6.  
  7. typedef struct sectionName {
  8.     char *    name;
  9.     char *    suffix;
  10. } SectionNameRec;
  11.  
  12. #ifdef SYSV
  13.  
  14. static SectionNameRec SectionNames[] = {
  15.     {"(1) User Commands",        "1"},
  16.     {"(1m) Sys, Administration",    "1m"},
  17.     {"(2) System Calls",        "2"},
  18.     {"(3) Subroutines",            "3"},
  19.     {"(4) File Formats",        "4"},
  20.     {"(5) Miscellaneous",        "5"},
  21.     {"(6) Games",            "6"},
  22.     {"(7) Devices",            "7"},
  23.     {"(8) Sys. Administration",        "8"},
  24.     {"(l) Local",            "l"},
  25.     {"(n) New",                "n"},
  26.     {"(o) Old",                "o"}
  27. };
  28.  
  29. #else
  30.  
  31. static SectionNameRec SectionNames[] = {
  32.     {"(1) User Commands",        "1"},
  33.     {"(2) System Calls",        "2"},
  34.     {"(3) Subroutines",            "3"},
  35.     {"(4) Devices",            "4"},
  36.     {"(5) File Formats",        "5"},
  37.     {"(6) Games",            "6"},
  38.     {"(7) Miscellaneous",        "7"},
  39.     {"(8) Sys. Administration",        "8"},
  40.     {"(l) Local",            "l"},
  41.     {"(n) New",                "n"},
  42.     {"(o) Old",                "o"},
  43. #ifdef sony
  44.     {"(p) Public Domain",        "p"},
  45.     {"(s) Sony Specific",        "s"},
  46. #endif
  47. };
  48.  
  49. #endif
  50.  
  51.  
  52. /*    Function Name: AddStandardSections
  53.  *    Description: Adds all the standard sections to the list for this path.
  54.  *    Arguments: list - a pointer to the section list.
  55.  *                 path - the path to these standard sections.
  56.  *    Returns: none.
  57.  */
  58.  
  59. void AddStandardSections(list, path)
  60. SectionList **list;
  61. char * path;
  62. {
  63. #ifdef CRAY
  64.     AddStandardCraySections(list, path);
  65.     return;
  66. #else
  67.   register int i;
  68.   char file[BUFSIZ];
  69.   int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]);
  70.  
  71.   for (i=0; i < numSections; i++) {
  72.     sprintf(file, "%s%s", SEARCHDIR, SectionNames[i].suffix);
  73.     AddNewSection(list, path, file, SectionNames[i].name, TRUE);
  74. #ifdef SEARCHOTHER
  75.     sprintf(file, "%s%s", SEARCHOTHER, SectionNames[i].suffix);
  76.     AddNewSection(list, path, file, SectionNames[i].name, TRUE);
  77. #endif
  78.   }
  79. #endif
  80. }
  81.  
  82. #ifdef CRAY
  83. /*    Function Name: AddStandardCraySections
  84.  *    Description: Add sections specific to the Cray.
  85.  *    Arguments: list - a pointer to the section list.
  86.  *                 path - the path to these standard sections.
  87.  *                 names - standard section names.
  88.  *    Returns: none.
  89.  */
  90.  
  91. AddStandardCraySections(list, path)
  92. SectionList **list;
  93. char *path;
  94. {
  95.   char file[BUFSIZ];
  96.   int i;
  97. #define NoSuf  (char *)0
  98. #define Suffix (char *)1
  99. #define Fold (char *)2
  100. #define FoldSuffix (char *)3
  101.   static char *cname[] = {
  102.     "(1) User Commands",    Suffix,    "1",    "1bsd",    NULL,
  103.     "(1) User Commands (instant)",    NoSuf,    "1r",    "1rb",    NULL,
  104.     "(1m) System Administration",    NoSuf,    "1m",    NULL,
  105.     "(2) System Calls",        Suffix,    "2",    NULL,
  106.     "(3) Subroutines",        FoldSuffix,    "3",    "3bsd",    "3c",    "3m",    "3mt",    "3s",    "3sl",    "3z",    NULL,
  107.     "(3) Subroutines (FORTRAN)", Fold,    "3f",    NULL,
  108.     "(3) Subroutines (I/O)",    Fold,    "3io",    NULL,
  109.     "(3) Subroutines (X11)",    NoSuf,    "3X11",    NULL,
  110.     "(3) Subroutines (Xt)",    NoSuf,    "3Xt",    NULL,
  111.     "(3) Subroutines (misc.)",    Suffix,    "3q",    NULL,
  112.     "(3) Subroutines (misc.)",    Fold,    "3x",    NULL,
  113.     "(3) Subroutines (networking)",    Suffix,    "3n",    "3rpc",    "3svc",    "3w",    "3yp",    NULL,
  114.     "(3) Subroutines (scientific)",    Fold,    "3sci",    NULL,
  115.     "(3) Subroutines (utilities)",    FoldSuffix,    "3db",    "3u",    NULL,
  116.     "(4) Devices",        Suffix,    "4",    "4d",    "4f",    "4n",    "4p",    "4s",    NULL,
  117.     "(5) File Formats",        Suffix,    "5",    NULL,
  118.     "(6) Games",        Suffix,    "6",    NULL,
  119.     "(7) Miscellaneous",    Suffix,    "7",    NULL,
  120.     "(8) Sys. Administration",    NoSuf,    "8",    NULL,
  121.     "(l) Local",        Suffix,    "l",    NULL,
  122.     "(n) New",            Suffix,    "n",    NULL,
  123.     "(o) Old",            Suffix,    "o",    NULL,
  124.     "(info) Information",    NoSuf,    "info",    NULL,
  125.     "(osi) Miscellaneous",    NoSuf,    "osi",    NULL,
  126.     "(sl) Miscellaneous",    NoSuf,    "sl",    NULL,
  127.     "(ultra) Miscellaneous",    NoSuf,    "ultra",    NULL,
  128.     NULL
  129.   };
  130.   char **p = cname;
  131.  
  132.   while (*p != NULL) {
  133.     char *message = *p++;
  134.     int flags = (int) *p++;
  135.     while (*p != NULL) {
  136.       sprintf(file, "%s%s", SEARCHDIR, *p++);
  137.       AddNewSection(list, path, file, message, flags);
  138.     }
  139.     p++;
  140.   }
  141. }
  142. #endif /* CRAY */
  143.  
  144.  
  145. /*    Function Name: CreateManpageName
  146.  *    Description: Creates the manual page name for a given item.
  147.  *    Arguments: entry - the entry to convert.
  148.  *    Returns: the manual page properly allocated.
  149.  */
  150.  
  151. /*
  152.  * If the filename is foo.3     - Create an entry of the form:  foo
  153.  * If the filename is foo.3X11  - Create an entry of the form:  foo(X11)
  154.  * IF the filename is a.out.1   - Create an entry of the form:  a.out
  155.  */
  156.  
  157. char *
  158. CreateManpageName(entry, section, flags)
  159. char * entry;
  160. int section;
  161. int flags;
  162. {
  163.   char * cp;
  164.   char *p;
  165.   char page[BUFSIZ];
  166.   char sect[BUFSIZ];
  167.  
  168.   ParseEntry(entry, NULL, sect, page);
  169.  
  170. #ifndef CRAY
  171.   if ( (cp = rindex(page, '.')) != NULL)
  172.     if ( (int)strlen(cp) > 2 ) {
  173.       *cp++ = '(';
  174.       while( (cp[1] != '\0') ) {
  175.     *cp = *(cp + 1); 
  176.     cp++;
  177.       }
  178.       *cp++ = ')';
  179.       *cp = '\0';
  180.     }
  181.     else
  182.       *cp = '\0';
  183.  
  184. #else    /* CRAY    - pick up the Cray name from the section */
  185.  
  186.   if ( (cp = rindex(page, '.')) == NULL)
  187.     cp = page + strlen(page);
  188.   if ((flags & MSUFFIX) && strlen(sect) > 4) {
  189.     p = sect + 4;
  190.     *cp++ = '(';
  191.     while (*p)
  192.       *cp++ = *p++;
  193.     *cp++ = ')';
  194.   }
  195.   *cp = '\0';  
  196.  
  197. #endif    /* CRAY */
  198.   
  199.   return(StrAlloc(page));
  200. }
  201.